#!/usr/bin/python

import sys 
from collections import defaultdict

from veil import *

def parent_dict_factor():
  return defaultdict(int)

if __name__ == "__main__":
    OUTFILE = open( PERF_DIR + "total.csv", "w")    
    output = defaultdict(parent_dict_factor)
    filenames = sys.argv[1:]
    for file in filenames:
        INFILE = open( file, "r")
        lines = INFILE.readlines()
        for line in lines:
            points = line.split(',')
            j = 0
            for point in points[1:]:
                output[int(points[0])][j] += int(point)
                j += 1
    
    for key in sorted(output.iterkeys()):
        line = str(key)
        for key,item in output[key].iteritems():
            line += ","+str(item) 
        OUTFILE.write(line+"\n")


    OUTFILE.close()        
        



